package myjava.overriding;

import java.io.IOException;
import java.sql.SQLClientInfoException;
import java.util.InputMismatchException;

public class Root5 {

   public static void main(String[] args) {

   }
}

// overriding ed eccezioni

/* # UNCHECKED #
   no rules fai quello che vuoi: the overriding method can do what it wants */
class A {

   public void foo() { }
}

class B extends A {

   @Override
   // public void foo() throws NullPointerException { }
   // public void foo() throws RuntimeException { }
   // public void foo() throws ArithmeticException { }
   public void foo() throws InputMismatchException { }
}

/* # CHECKED #
   the overrding method can only throw
   - narrower exceptions
   - no exception at all
   - unchecked exceptions */

class C {

   public void foo() throws Exception { }
}

class D extends C {

   @Override
   // public void foo() throws IOException { }
   // public void foo() throws RuntimeException { }
   public void foo() { }
}